#pragma once
#include "HashTable.hpp"

namespace zty
{
  template <class K, class V, class Hash = Hashkey<K>>
  class unordered_map{
    struct MapKofT{
      const K& operator()(const pair<K,V>& kv){
        return kv.first;
      }
    };
    typedef HashTable<K,pair<K,V>,Hash,MapKofT> HT;
    HT _ht;

  public:
    typedef typename HT::iterator iterator;
    iterator begin(){
      return _ht.begin();
    }
    iterator end(){
      return _ht.end();
    }

    pair<iterator, bool> insert(const pair<K,V>& kv){
      return _ht.insert(kv);
    }

    V& operator[](const K& key){
      auto ret = _ht.insert(make_pair(key, V()));
      return ret.first->second;
    }

    iterator find(const K& key){
      return _ht.find(key);
    }

    bool erase(const K& key){
      return _ht.erase(key);
    }

  };
}
